//
//  YWLoginTool.m
//  maintain
//
//  Created by 郑想 on 15/10/23.
//  Copyright © 2015年 ewin. All rights reserved.
//

#import "YWLoginTool.h"
#import "NSString+md5.h"
#import "YWConst.h"
#import "YWMacro.h"
#import "WMHttpTool.h"
#import "YWCommonTool.h"
#import "MJExtension.h"

#import "YWLoginUser.h"
#import "YWOrganization.h"
#import "YWDictMaintenanceType.h"

#import "YWPushManager.h"
#import "YWEwinManager.h"
#import "YWDBTool.h"

#define kLoginAccountSaveDir [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define kLoginAccountSaveFileName @"loginAccount.data"
//临时任务
#define KPushTempMissionUserDefaultKey  [NSString stringWithFormat:@"%@%ld",@"pushTempMissionNoRedCount",(long)[YWLoginTool loginUser].uniqueId]
//通知
#define KPushNoticeUserDefaultKey  [NSString stringWithFormat:@"%@%ld",@"pushNoticeNoRedCount",(long)[YWLoginTool loginUser].uniqueId]

#define KPushMessageUserDefaultKey  [NSString stringWithFormat:@"%@%ld",@"pushMessageNoRedCount",(long)[YWLoginTool loginUser].uniqueId]
//报障
#define KPushReportTroubleDefaultKey  [NSString stringWithFormat:@"%@%ld",@"pushReportTroubleNoReadCount",(long)[YWLoginTool loginUser].uniqueId]
//检测
#define KPushDetectMissionNoReadUserDefaultKey  [NSString stringWithFormat:@"%@%ld",@"pushDetectMissionNoRedCount",(long)[YWLoginTool loginUser].uniqueId]
//保养
#define KPushUpkeepMissionNoReadUserDefaultKey  [NSString stringWithFormat:@"%@%ld",@"pushUpkeepMissionNoRedCount",(long)[YWLoginTool loginUser].uniqueId]
//维修
#define KPushTroubleMissionNoReadUserDefaultKey  [NSString stringWithFormat:@"%@%ld",@"pushTroubleMissionNoRedCount",(long)[YWLoginTool loginUser].uniqueId]
//巡查
#define KPushInspectionMissionNoReadUserDefaultKey  [NSString stringWithFormat:@"%@%ld",@"pushInspectionMissionNoRedCount",(long)[YWLoginTool loginUser].uniqueId]
//巡更
#define KPushKeepWatchMissionNoRedUserDefaultKey  [NSString stringWithFormat:@"%@%ld",@"pushKeepWatchMissionNoRedCount",(long)[YWLoginTool loginUser].uniqueId]
//物料
#define KPushMaterialNoReadDefaultKey  [NSString stringWithFormat:@"%@%ld",@"pushMaterialNoReadCount",(long)[YWLoginTool loginUser].uniqueId]
//清点
#define KPushAssetsInventoryNoReadDefaultKey  [NSString stringWithFormat:@"%@%ld",@"pushAssetsInventoryNoReadCount",(long)[YWLoginTool loginUser].uniqueId]
//提醒
#define KPushWorkReminderNoRedCountDefaultKey [NSString stringWithFormat:@"%@%ld",@"KPushWorkReminderNoRedCountKey",(long)[YWLoginTool loginUser].uniqueId]
//监控报警
#define KPushMonitorAlarmNoRedCountDefaultKey [NSString stringWithFormat:@"%@%ld",@"KPushMonitorAlarmNoRedCountKey",(long)[YWLoginTool loginUser].uniqueId]

//楼盘(自定义名称，如工厂)
#define KCustomDefineBuildingShowName  @"KCustomDefineBuildingShowName"
#define KCustomDefineApartmentShowName  @"KCustomDefineApartmentShowName"
#define KCustomDefineFloorShowName  @"KCustomDefineFloorShowName"
#define KCustomDefineLocationShowName  @"KCustomDefineLocationShowName"

@implementation YWLoginTool

+ (BOOL)isLogin
{
    BOOL loginStatus = [[NSUserDefaults standardUserDefaults] boolForKey:kLoginStatus];
    return loginStatus;
}

+ (NSString*)savefilePath
{
    NSString* filePath = [kLoginAccountSaveDir stringByAppendingPathComponent:kLoginAccountSaveFileName];
    return filePath;
}

+ (BOOL)saveLoginOfUser:(YWLoginUser*)user
{
    BOOL result = [NSKeyedArchiver archiveRootObject:user toFile:[self savefilePath]];
    return result;
}

+ (YWLoginUser*)loginUser
{
    YWLoginUser* user = [NSKeyedUnarchiver unarchiveObjectWithFile:[self savefilePath]];
    return user;
}

+ (void)saveRequestHeadAppKey:(NSString*)appKey
{
    [[NSUserDefaults standardUserDefaults] setObject:appKey forKey:kRequestHeadAppKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (NSString*)requestHeadAppKey
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:kRequestHeadAppKey];
}

+ (void)saveLoginofStatus:(BOOL)status
{
    [[NSUserDefaults standardUserDefaults] setBool:status forKey:kLoginStatus];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (NSString*)DBName
{
    YWLoginUser* user = [YWLoginTool loginUser];
    return [NSString stringWithFormat:@"%@%ld", user.companyAccount, (long)user.uniqueId];
}

+ (void)preLoginRequestWithUserName:(NSString *)userName passWord:(NSString *)passWord isLogin:(BOOL)isLogin completeBlock:(void (^)(NSArray *))complete{
    [WMHttpTool shareHttpTool].HTTPHeaders = @{ @"clientType" : @"app" };
    NSDictionary *params = @{ @"username" : userName,
                              @"password" : [passWord md5] };
    
    [[WMHttpTool shareHttpTool] postWithUrl:[YWCommonTool preLoginUrl] params:params success:^(NSHTTPURLResponse* response, id json) {
        NSArray* organizations = [YWOrganization mj_objectArrayWithKeyValuesArray:json];
        if (complete) {
            complete(organizations);
        }
    } failure:^(NSHTTPURLResponse* response, NSError* error) {
        YWLog(@"%s,error:%@", __func__, error.localizedDescription);
        if (complete) {
            complete(nil);
        }
        if (isLogin) {
            if (400 == response.statusCode) {
                [YWCommonTool showTextHUDWithContent:NSLocalizedString(kTextLoginAccountOrPwdError, nil)];
            }else if (404 == response.statusCode) {
                [YWCommonTool showTextHUDWithContent:NSLocalizedString(kTextLoginAccountNoExist, nil)];
            }else if (423 == response.statusCode) {
                [YWCommonTool showTextHUDWithContent:NSLocalizedString(kTextLoginAccountNoActivate, nil)];
            }else {
                [YWCommonTool showTextHUDWithContent:NSLocalizedString(kTextLoginFail, nil)];
            }
        }else{
            if (![[WMHttpTool shareHttpTool] existenceNetwork]) {
                [YWCommonTool showTextHUDWithContent:NSLocalizedString(kTextNoNetwork, nil)];
                return;
            }
        }
    }];
}

+ (void)loginRequestWithOrganizationNo:(NSString *)organizationNo simpleName:(NSString *)simpleName userName:(NSString *)userName passWord:(NSString *)passWord isLogin:(BOOL)isLogin completeBlock:(void (^)(NSInteger))complete{
    [WMHttpTool shareHttpTool].HTTPHeaders = @{ @"clientType" : @"app" };
    
//    __block NSString* userAccount = userName;
//    __block NSString* copyCompanyAccount = [companyAccount copy];
    
    NSDictionary* params = @{ @"companyCode" : organizationNo,
                              @"username" : userName,
                              @"password" : [passWord md5] };
    
    [[WMHttpTool shareHttpTool] postWithUrl:[YWCommonTool loginUrl] params:params success:^(NSHTTPURLResponse* response, id json) {
        //登录成功,保存用户信息
        NSString* appKey = [response.allHeaderFields objectForKey:@"app_key"];
        NSMutableDictionary* userJson = [NSMutableDictionary dictionaryWithDictionary:json];
        [userJson setObject:organizationNo forKey:@"companyAccount"];
        [userJson setObject:simpleName forKey:@"simpleName"];
        [userJson setObject:userName forKey:@"userAccount"];
        [userJson setObject:passWord forKey:@"userPwd"];
        YWLoginUser* user = [YWLoginUser mj_objectWithKeyValues:userJson];
        [YWLoginTool saveRequestHeadAppKey:appKey];
        [YWLoginTool saveLoginofStatus:YES];
        [YWLoginTool saveLoginOfUser:user];
        
        //保存楼盘,楼栋,楼层,位置的别名
        YWOrganization* organization = [YWOrganization mj_objectWithKeyValues:[json objectForKey:@"organization"]];
        if (organization.customShowName) {
            [YWLoginTool saveCustomDefineBuildingShowName:organization.customShowName.buildingShowName];
            [YWLoginTool saveCustomDefineApartmentShowName:organization.customShowName.apartmentShowName];
            [YWLoginTool saveCustomDefineFloorShowName:organization.customShowName.floorShowName];
            [YWLoginTool saveCustomDefineLocationShowName:organization.customShowName.locationShowName];
        }
        //设置友盟
        [[YWPushManager shareManager] setUpUMengAliasWithUser:user];
        [[YWPushManager shareManager] setUpUMengTagsWithUser:user];
        //设置3G/4G开关
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:KNetWorkType];
        [[NSUserDefaults standardUserDefaults] synchronize];
        
        //清除掉记忆的楼盘,楼栋,楼层
        NSString *buildingPath = [kLoginAccountSaveDir stringByAppendingPathComponent:KYWRememberLastBuilding];
        if ([[NSFileManager defaultManager] fileExistsAtPath:buildingPath]) {
            [[NSFileManager defaultManager] removeItemAtPath:buildingPath error:nil];
        }
        NSString *apartmentPath = [kLoginAccountSaveDir stringByAppendingPathComponent:KYWRememberLastApartment];
        if ([[NSFileManager defaultManager] fileExistsAtPath:apartmentPath]) {
            [[NSFileManager defaultManager] removeItemAtPath:apartmentPath error:nil];
        }
        NSString *floorPath = [kLoginAccountSaveDir stringByAppendingPathComponent:KYWRememberLastFloor];
        if ([[NSFileManager defaultManager] fileExistsAtPath:floorPath]) {
            [[NSFileManager defaultManager] removeItemAtPath:floorPath error:nil];
        }
        //连接数据库
        [[YWDBTool shareDBTool] connectDB:[YWLoginTool DBName]];
        YWLog(@"DB path: %@", [[YWDBTool shareDBTool] dbPath]);
        
        //上传设备信息
        NSString* token = [[YWPushManager shareManager] deviceToken];
        [[YWEwinManager shareManager] uploadDeviceInfoWithDeviceToken:token IsLogin:1 WithComplete:nil];
        if (complete) {
            complete(response.statusCode);
        }
        
    } failure:^(NSHTTPURLResponse* response, NSError* error) {
        YWLog(@"%s,error:%@", __func__, error.localizedDescription);
        if (complete) {
            complete(response.statusCode);
        }
        if (isLogin) {
            if (400 == response.statusCode) {
                [YWCommonTool showTextHUDWithContent:NSLocalizedString(kTextLoginAccountOrPwdError, nil)];
            }else if (404 == response.statusCode) {
                [YWCommonTool showTextHUDWithContent:NSLocalizedString(kTextLoginAccountNoExist, nil)];
            }else if (423 == response.statusCode) {
                [YWCommonTool showTextHUDWithContent:NSLocalizedString(kTextLoginAccountNoActivate, nil)];
            }else {
                [YWCommonTool showTextHUDWithContent:NSLocalizedString(kTextLoginFail, nil)];
            }
        }else{
            if (![[WMHttpTool shareHttpTool] existenceNetwork]) {
                [YWCommonTool showTextHUDWithContent:NSLocalizedString(kTextNoNetwork, nil)];
                return;
            }
        }
    }];
}



+ (void)saveTempMissionNoRedCount
{
    NSInteger count = [YWLoginTool tempMissionNoRedCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count+1) forKey:KPushTempMissionUserDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (void)saveTempMissionWithNoRedCount:(NSInteger)count{
    //NSInteger counttt = [YWLoginTool tempMissionNoRedCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count) forKey:KPushTempMissionUserDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (NSInteger)tempMissionNoRedCount
{
    return [[[NSUserDefaults standardUserDefaults] objectForKey:KPushTempMissionUserDefaultKey] integerValue];
}

+ (void)clearTempMissionNoRedCount{
    [[NSUserDefaults standardUserDefaults] setObject:@(0) forKey:KPushTempMissionUserDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (void)saveNoticeNoRedCount
{
    NSInteger count = [YWLoginTool noticeNoRedCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count+1) forKey:KPushNoticeUserDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (void)saveNoticeWithNoRedCount:(NSInteger)count{
    //NSInteger counttt = [YWLoginTool noticeNoRedCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count) forKey:KPushNoticeUserDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (void)clearNoticeNoRedCount{
    [[NSUserDefaults standardUserDefaults] setObject:@(0) forKey:KPushNoticeUserDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (NSInteger)noticeNoRedCount
{
    return [[[NSUserDefaults standardUserDefaults] objectForKey:KPushNoticeUserDefaultKey] integerValue];
}

+ (void)saveReportTroubleNoReadCount{
    NSInteger count = [YWLoginTool reportTroubleNoReadCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count+1) forKey:KPushReportTroubleDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (void)saveReportTroubleWithNoReadCount:(NSInteger)count{
    //NSInteger counttt = [YWLoginTool reportTroubleNoReadCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count) forKey:KPushReportTroubleDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (void)clearReportTroubleNoReadCount{
    [[NSUserDefaults standardUserDefaults] setObject:@(0) forKey:KPushReportTroubleDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSInteger)reportTroubleNoReadCount{
    return [[[NSUserDefaults standardUserDefaults] objectForKey:KPushReportTroubleDefaultKey] integerValue];
}

+ (void)saveMaterialNoReadCount{
    NSInteger count = [YWLoginTool materialNoReadCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count+1) forKey:KPushMaterialNoReadDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (void)saveMaterialWithNoReadCount:(NSInteger)count{
    //NSInteger countt = [YWLoginTool materialNoReadCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count) forKey:KPushMaterialNoReadDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (void)clearMaterialNoReadCount{
    [[NSUserDefaults standardUserDefaults] setObject:@(0) forKey:KPushMaterialNoReadDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSInteger)materialNoReadCount{
    return [[[NSUserDefaults standardUserDefaults] objectForKey:KPushMaterialNoReadDefaultKey] integerValue];
}

+ (void)saveAssetsInventoryNoReadCount{
    NSInteger count = [YWLoginTool assetsInventoryNoReadCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count+1) forKey:KPushAssetsInventoryNoReadDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (void)saveAssetsInventoryWithNoReadCount:(NSInteger)count{
    [[NSUserDefaults standardUserDefaults] setObject:@(count) forKey:KPushAssetsInventoryNoReadDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (void)clearAssetsInventoryNoReadCount{
    [[NSUserDefaults standardUserDefaults] setObject:@(0) forKey:KPushAssetsInventoryNoReadDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSInteger)assetsInventoryNoReadCount{
    return [[[NSUserDefaults standardUserDefaults] objectForKey:KPushAssetsInventoryNoReadDefaultKey] integerValue];
}


+ (void)saveMissionNoRedCountWithMaintenanceType:(NSInteger)maintenanceType{
    NSString *userDefaultKey = [YWLoginTool userNoReadMissionCountDefaultKey:maintenanceType];
    if (userDefaultKey) {
        NSInteger count = [YWLoginTool missionNoRedCountWithMaintenanceType:maintenanceType];
        [[NSUserDefaults standardUserDefaults] setObject:@(count+1) forKey:userDefaultKey];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}
+ (void)saveMissionNoRedCountWithMaintenanceType:(NSInteger)maintenanceType noReadCount:(NSInteger)count{
    NSString *userDefaultKey = [YWLoginTool userNoReadMissionCountDefaultKey:maintenanceType];
    if (userDefaultKey) {
        //NSInteger countt = [YWLoginTool missionNoRedCountWithMaintenanceType:maintenanceType];
        [[NSUserDefaults standardUserDefaults] setObject:@(count) forKey:userDefaultKey];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}
+ (void)clearMissionNoRedCountWithMaintenanceType:(NSInteger)maintenanceType{
    NSString *userDefaultKey = [YWLoginTool userNoReadMissionCountDefaultKey:maintenanceType];
    [[NSUserDefaults standardUserDefaults] setObject:@(0) forKey:userDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (NSInteger)missionNoRedCountWithMaintenanceType:(NSInteger)maintenanceType{
    NSString *userDefaultKey = [YWLoginTool userNoReadMissionCountDefaultKey:maintenanceType];
    return userDefaultKey ? [[[NSUserDefaults standardUserDefaults] objectForKey:userDefaultKey] integerValue] : 0;
}

+ (NSString *)userNoReadMissionCountDefaultKey:(NSInteger)maintenanceType{
    NSString *userDefaultKey = nil;
    if (maintenanceType == YWMaintenanceTypePatrol) {
        userDefaultKey = KPushInspectionMissionNoReadUserDefaultKey;
    }else if (maintenanceType == YWMaintenanceTypeDetection){
        userDefaultKey = KPushDetectMissionNoReadUserDefaultKey;
    }else if (maintenanceType == YWMaintenanceTypeUpkeep){
        userDefaultKey = KPushUpkeepMissionNoReadUserDefaultKey;
    }else if (maintenanceType == YWMaintenanceTypeTrouble){
        userDefaultKey = KPushTroubleMissionNoReadUserDefaultKey;
    }else if (maintenanceType == YWMaintenanceTypeKeepWatch){
        userDefaultKey = KPushKeepWatchMissionNoRedUserDefaultKey;
    }
    return userDefaultKey;
}

+ (NSInteger)noticeAndTempMissionTotalNoRedCount{
    NSInteger noticeNoRed = [YWLoginTool noticeNoRedCount];
    NSInteger tempMissionNoRed = [YWLoginTool tempMissionNoRedCount];
    return  noticeNoRed + tempMissionNoRed;
}

+ (void)clearNoticeAndTempMissionTotalNoRedCount{
    [self clearNoticeNoRedCount];
    [self clearTempMissionNoRedCount];
}

+ (void)savePushMessageNoRedCount
{
    NSInteger count = [YWLoginTool pushMessageNoRedCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count+1) forKey:KPushMessageUserDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (void)clearPushMessageNoRedCount{
    [[NSUserDefaults standardUserDefaults] setObject:@(0) forKey:KPushMessageUserDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (NSInteger)pushMessageNoRedCount
{
    return [[[NSUserDefaults standardUserDefaults] objectForKey:KPushMessageUserDefaultKey] integerValue];
}

//
+ (void)saveWorkReminderNoRedCount{
    NSInteger count = [YWLoginTool WorkReminderNoRedCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count+1) forKey:KPushWorkReminderNoRedCountDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (void)saveWorkReminderNoRedWithCount:(NSInteger)count{
    [[NSUserDefaults standardUserDefaults] setObject:@(count) forKey:KPushWorkReminderNoRedCountDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (void)clearWorkReminderNoRedCount{
    [[NSUserDefaults standardUserDefaults] setObject:@(0) forKey:KPushWorkReminderNoRedCountDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSInteger)WorkReminderNoRedCount{
    return [[[NSUserDefaults standardUserDefaults] objectForKey:KPushWorkReminderNoRedCountDefaultKey] integerValue];
}

+ (void)saveMonitorAlarmNoRedCount{
    NSInteger count = [YWLoginTool monitorAlarmNoRedCount];
    [[NSUserDefaults standardUserDefaults] setObject:@(count+1) forKey:KPushMonitorAlarmNoRedCountDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (void)saveMonitorAlarmNoRedWithCount:(NSInteger)count{
    [[NSUserDefaults standardUserDefaults] setObject:@(count) forKey:KPushMonitorAlarmNoRedCountDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (void)clearMonitorAlarmNoRedCount{
    [[NSUserDefaults standardUserDefaults] setObject:@(0) forKey:KPushMonitorAlarmNoRedCountDefaultKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSInteger)monitorAlarmNoRedCount{
    return [[[NSUserDefaults standardUserDefaults] objectForKey:KPushMonitorAlarmNoRedCountDefaultKey] integerValue];
}

//自定义楼盘名
+ (void)saveCustomDefineBuildingShowName:(NSString*)buildingShowName{
    [[NSUserDefaults standardUserDefaults] setObject:buildingShowName.length?buildingShowName:NSLocalizedString(@"building", nil) forKey:KCustomDefineBuildingShowName];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSString*)buildingShowName{
    return [NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:KCustomDefineBuildingShowName]?:@""];
}
//自定义楼栋名
+ (void)saveCustomDefineApartmentShowName:(NSString*)apartmentShowName{
    [[NSUserDefaults standardUserDefaults] setObject:apartmentShowName.length?apartmentShowName:NSLocalizedString(@"apartment", nil) forKey:KCustomDefineApartmentShowName];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSString*)apartmentShowName{
    return [NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:KCustomDefineApartmentShowName]?:@""];
}
//自定义楼层名
+ (void)saveCustomDefineFloorShowName:(NSString*)floorShowName{
    [[NSUserDefaults standardUserDefaults] setObject:floorShowName.length?floorShowName:NSLocalizedString(@"floor", nil) forKey:KCustomDefineFloorShowName];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSString*)floorShowName{
    return [NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:KCustomDefineFloorShowName]?:@""];
}
//自定义位置名
+ (void)saveCustomDefineLocationShowName:(NSString*)locationShowName{
    [[NSUserDefaults standardUserDefaults] setObject:locationShowName.length?locationShowName:NSLocalizedString(@"location", nil) forKey:KCustomDefineLocationShowName];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSString*)locationShowName{
    return [NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:KCustomDefineLocationShowName]?:@""];
}

@end
